Repository navigation
feat(labels): a clearance per label class keeps the room round its labels free of other labels (#2828) - #2833
jgregoriorincon wants to merge 2 commits into
Conversation
…bels free of other labels (opengeos#2828)
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Checked and left alone: there were no prior review threads, so nothing was skipped. I confirmed that the load-time notices cover layers and styles, that the lenient parse matches the audit's adjusted check, and that the Change sizeCompared with the base branch: merge base 463133b to PR head 74e97c4.
|
…, not at its class's clearance (opengeos#2828)
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
|
Code reviewI found no bugs, security problems, or AGENTS.md breaks in this PR. I read the full diff and the surrounding code, but did not build or run the tests. Bugs
Security
Performance
Quality
AGENTS.md
Earlier concerns left alone: 2. Both threads on No inline comments were posted, since nothing here rises above a nit. Change sizeCompared with
|
Summary
Step 3b of #995: a clearance on each label class, the room its labels keep free of other labels. Until now every layer label kept the same 2 points clear of the others (
Collide::default().text_padding), and nothing let a class change it: a map couldn't keep its river or district names well apart from the rest, nor pack small labels tighter where room is short.label_boxes,crates/render/src/lib.rs); a layer's label now takes its class's clearance as that padding instead of the fixed 2. So two labels keep both their clearances apart, as before: 10 and 2 keep their texts at least 12 points apart (beyond their halos). Turned and curved labels' boxes grow by it as a straight one's do, and a callout looks for a spot clear of it. No new mechanism: the padding was already there.labels.placementtakes"clearance": a number of points from 0 to 100; a fraction is kept; a number past 0 or 100 is brought to it, with a notice;nullis 2; text that isn't a number is refused.LabelClass::clearanceis read with#[serde(default)]and left out at 2, so existing projects draw and save as before. A project, map file or layer file with another clearance requires the newlabel-clearancecapability, so an older RustGIS refuses it rather than dropping the clearances (docs/maintaining.md; fixtureschema/fixtures/label_clearance.rgis). A clearance in a file that isn't a number from 0 to 100 is read held to that range (or as 2 when it isn't a number), with one notice on opening. A saved style with such a class, and a savedlabels.placementstep with a clearance other than 2 (in a task, a model or a script), requirelabel-clearancetoo, since an older reader would apply the style, or run the step, without it.text-padding; graphics' text and grid labels keep 2. Icons keep their own padding. A clearance change keeps a lock.docs/maintaining.mdlists the capability.Not in this PR:
Testing
cargo fmt --all -- --check,cargo clippyon the four crates with--all-targets -- -D warnings,cargo nextest run --workspace(9306 passed; the local DuckDB tests left out),cargo test --workspace --doc,cargo xtask layers,cargo xtask schema --check(60 fixture projects open): all pass.command-surface.txtlists the new key.a_label_class_keeps_its_clearance_free_of_other_labels(render): two point layers 6 points apart between their halos keep both labels at 2 + 2; 5 on either one (5 + 2 > 6) leaves the lower one out; 3.9 (a fraction) keeps both; a point apart, 2 + 2 keep one out and 0 + 0 let both in; a label moved by hand keeps its class's clearance. Seen failing with the padding still fixed at 2.a_label_class_takes_a_clearance(engine): the command, a fraction and a number in text kept, 500 and -3 held with their notices, refusals with their message,null, a named class, undo, a lock kept,requires, nothing written at 2, the fixture, and a damaged clearance in a file said once.saved_label_clearances_are_required_by_name(engine): a task step with 8, 0, "8", 2.5 or 500 requireslabel-clearance; 2, null or no clearance don't; in a script; a saved style.a_label_clearance_is_set_in_the_pane(desktop): the class's clearance shown, a typed 9.5 set, a slow drag in one undo step, and another layer chosen mid-drag leaving both layers' clearances and the undo history as they were.hostile_params_never_paniccovers the new key through the command's description.UI evidence
The World Atlas sample over central Europe, the Cities labels on. Before (left, every class at 2): Bern, Budapest, Sarajevo and Belgium's name are drawn. After (right, Cities at 12): those labels are left out where a city's 12 points would reach them. With Cities back at 2 the map is the same, pixel for pixel, as before the change.
The new Clearance row in Labeling pane › Position, under Weight:
Reach every surface
rustgis-render, which all of them draw labels with; the setting goes throughlabels.placement, which the pane, scripts, the command line, Python, the Assistant and MCP call.labels.placement's description lists the new key, so command search, the Assistant, MCP and plugins see it.labels.placementwith a clearance undoes in one step;nullputs the default back.New strings (
Clearanceand its hover text) wait for the release translation pass.Related issue
Closes #2828 (part of #995).